package com.yupi.maker.generator;

import java.io.*;
import java.util.Map;

/**
 * 生成.git文件
 */
public class GitGenerator {

    public static void doGenerate(String projectDir) throws IOException, InterruptedException {
        // 将项目变成ignore文件
        String gitCommand = "git init";

        // 这里一定要用空格拆分！
        ProcessBuilder processBuilder = new ProcessBuilder(gitCommand.split(" "));
        processBuilder.directory(new File(projectDir));

        Process process = processBuilder.start();
//        // 读取命令的输出
//        InputStream inputStream = process.getInputStream();
//        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
//        String line;
//        while ((line = reader.readLine()) != null) {
//            System.out.println(line);
//        }
        // 等待命令执行完成
        int exitCode = process.waitFor();
        System.out.println("命令执行结束，退出码：" + exitCode);
    }
}
